package com.lingyun.financialmanagement.utils;

import com.lingyun.financialmanagement.vo.ErrorCode;
import com.lingyun.financialmanagement.vo.Result;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.net.URLEncoder;

public class ExcelSetting {
    public static void excelSetting(HttpServletResponse response){
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        String fileName;
        try{
            fileName = URLEncoder.encode("用户数据.xlsx", "UTF-8");
        } catch (Exception e){
            throw new RuntimeException("Excel配置错误");
        }
        response.setHeader("Content-disposition", "attachment;filename=" + fileName);

    }
}
